package com.huiw.archives.modules.sys.entity;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

@MappedSuperclass
public abstract class BaseEntity {

	/**
	 * 新的实例
	 */
	protected BaseEntity() {

		// 生成新的guid
		this.pid = java.util.UUID.randomUUID().toString().replaceAll("\\-", "");
		// 得到当前时间，转换为字符串并放入属性中
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		java.util.Date dt = new Date();
		this.sysCreateTime = sdf.format(dt);
		this.lastModifyTime = this.sysCreateTime;
	}

	/**
	 * 存在的实例
	 * 
	 * @param objguid
	 */
	protected BaseEntity(String pid) {

		if (!pid.equals("") && pid != null) {
			this.pid = pid;
			// 得到当前时间，转换为字符串并放入最后修改时间属性中
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			java.util.Date dt = new Date();
			this.lastModifyTime = sdf.format(dt);
		} else {

		}
	}

	/**
	 * 主键，系统内唯一标识值
	 */
	protected String pid;

	@Id
	@Column(name = "pid")
	public String getPid() {
		return pid;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}

	/**
	 * 自增值，用于查询
	 */
	protected Integer sysSeq;

	public void setSysSeq(Integer sysSeq) {
		this.sysSeq = sysSeq;
	}

	@Column(name = "sys_seq", nullable = false, insertable = false)
	public Integer getSysSeq() {
		return sysSeq;
	}

	/**
	 * 系统创建时间
	 */
	protected String sysCreateTime;

	@Column(name = "sys_create_time")
	public String getSysCreateTime() {
		return sysCreateTime;
	}

	public void setSysCreateTime(String sysCreateTime) {
		this.sysCreateTime = sysCreateTime;
	}

	/**
	 * 系统最后修改时间
	 */
	protected String lastModifyTime;

	@Column(name = "last_modify_time")
	public String getLastModifyTime() {
		return lastModifyTime;
	}

	public void setLastModifyTime(String lastModifyTime) {
		this.lastModifyTime = lastModifyTime;
	}

}
